package models

import (
	"doctor-srv/basic/config"
	"gorm.io/gorm"
)

// 问诊记录
type Record struct {
	gorm.Model
	PatientId     int    `json:"patient_id" gorm:"type:int;comment:'患者id'"`
	DoctorId      int    `json:"doctor_id" gorm:"type:int;comment:'医生id'"`
	ReservationId int    `json:"reservation_id" gorm:"type:int;comment:'预约id'"`
	Duration      string `json:"duration" gorm:"type:varchar(50);comment:'问诊时长'"`
	Status        int    `json:"status" gorm:"type:int;comment:'状态 1-已完成 2-待完成'"`
}

func (re *Record) TableName() string {
	return "record"
}

func (re *Record) AddRecord() error {
	return config.DB.Create(&re).Error
}

func (re *Record) GetRecord(id int) error {
	return config.DB.Model(&Record{}).Where("id = ?", id).Limit(1).Find(&re).Error
}
